home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / fastlane.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  12KB  |  345 lines

  1. /***************************************************************************
  2.  
  3. Fast Lane(GX752) (c) 1987 Konami
  4.  
  5. Driver by Manuel Abadia <manu@teleline.es>
  6.  
  7. TODO:
  8. - verify that sound is correct (volume and bank switching)
  9.  
  10. ***************************************************************************/
  11.  
  12. #include "driver.h"
  13. #include "cpu/m6809/m6809.h"
  14. #include "vidhrdw/generic.h"
  15. #include "vidhrdw/konamiic.h"
  16.  
  17. /* from vidhrdw/fastlane.c */
  18. extern unsigned char *fastlane_k007121_regs,*fastlane_videoram1,*fastlane_videoram2;
  19. WRITE_HANDLER( fastlane_vram1_w );
  20. WRITE_HANDLER( fastlane_vram2_w );
  21. int fastlane_vh_start(void);
  22. void fastlane_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  23.  
  24. static int fastlane_interrupt(void)
  25. {
  26.     if (cpu_getiloops() == 0)
  27.     {
  28.         if (K007121_ctrlram[0][0x07] & 0x02) return HD6309_INT_IRQ;
  29.     }
  30.     else if (cpu_getiloops() % 2)
  31.     {
  32.         if (K007121_ctrlram[0][0x07] & 0x01) return nmi_interrupt();
  33.     }
  34.     return ignore_interrupt();
  35. }
  36.  
  37. WRITE_HANDLER( k007121_registers_w )
  38. {
  39.     if (offset < 8)
  40.         K007121_ctrl_0_w(offset,data);
  41.     else    /* scroll registers */
  42.         fastlane_k007121_regs[offset] = data;
  43. }
  44.  
  45. static WRITE_HANDLER( fastlane_bankswitch_w )
  46. {
  47.     int bankaddress;
  48.     unsigned char *RAM = memory_region(REGION_CPU1);
  49.  
  50.     /* bits 0 & 1 coin counters */
  51.     coin_counter_w(0,data & 0x01);
  52.     coin_counter_w(1,data & 0x02);
  53.  
  54.     /* bits 2 & 3 = bank number */
  55.     bankaddress = 0x10000 + ((data & 0x0c) >> 2) * 0x4000;
  56.     cpu_setbank(1,&RAM[bankaddress]);
  57.  
  58.     /* bit 4: bank # for the 007232 (chip 2) */
  59.     RAM = memory_region(REGION_SOUND2);
  60.     K007232_bankswitch(1,RAM + 0x40000*((data & 0x10) >> 4),RAM + 0x40000*((data & 0x10) >> 4));
  61.  
  62.     /* other bits seems to be unused */
  63. }
  64.  
  65. /* Read and write handlers for one K007232 chip:
  66.    even and odd register are mapped swapped */
  67.  
  68. static READ_HANDLER( fastlane_K007232_read_port_0_r )
  69. {
  70.     return K007232_read_port_0_r(offset ^ 1);
  71. }
  72. static WRITE_HANDLER( fastlane_K007232_write_port_0_w )
  73. {
  74.     K007232_write_port_0_w(offset ^ 1, data);
  75. }
  76. static READ_HANDLER( fastlane_K007232_read_port_1_r )
  77. {
  78.     return K007232_read_port_1_r(offset ^ 1);
  79. }
  80. static WRITE_HANDLER( fastlane_K007232_write_port_1_w )
  81. {
  82.     K007232_write_port_1_w(offset ^ 1, data);
  83. }
  84.  
  85.  
  86.  
  87. static struct MemoryReadAddress fastlane_readmem[] =
  88. {
  89.     { 0x0000, 0x005f, MRA_RAM },
  90.     { 0x0800, 0x0800, input_port_2_r },        /* DIPSW #3 */
  91.     { 0x0801, 0x0801, input_port_5_r },        /* 2P inputs */
  92.     { 0x0802, 0x0802, input_port_4_r },        /* 1P inputs */
  93.     { 0x0803, 0x0803, input_port_3_r },        /* COINSW */
  94.     { 0x0900, 0x0900, input_port_0_r },        /* DIPSW #1 */
  95.     { 0x0901, 0x0901, input_port_1_r },        /* DISPW #2 */
  96.     { 0x0d00, 0x0d0d, fastlane_K007232_read_port_0_r },/* 007232 registers (chip 1) */
  97.     { 0x0e00, 0x0e0d, fastlane_K007232_read_port_1_r },/* 007232 registers (chip 2) */
  98.     { 0x0f00, 0x0f1f, K051733_r },            /* 051733 (protection) */
  99.     { 0x1000, 0x1fff, MRA_RAM },            /* Palette RAM/Work RAM */
  100.     { 0x2000, 0x3fff, MRA_RAM },            /* Video RAM + Sprite RAM */
  101.     { 0x4000, 0x7fff, MRA_BANK1 },            /* banked ROM */
  102.     { 0x8000, 0xffff, MRA_ROM },            /* ROM */
  103.     { -1 }    /* end of table */
  104. };
  105.  
  106. static struct MemoryWriteAddress fastlane_writemem[] =
  107. {
  108.     { 0x0000, 0x005f, k007121_registers_w, &fastlane_k007121_regs },/* 007121 registers */
  109.     { 0x0b00, 0x0b00, watchdog_reset_w },        /* watchdog reset */
  110.     { 0x0c00, 0x0c00, fastlane_bankswitch_w },    /* bankswitch control */
  111.     { 0x0d00, 0x0d0d, fastlane_K007232_write_port_0_w },    /* 007232 registers (chip 1) */
  112.     { 0x0e00, 0x0e0d, fastlane_K007232_write_port_1_w },    /* 007232 registers (chip 2) */
  113.     { 0x0f00, 0x0f1f, K051733_w },                /* 051733 (protection) */
  114.     { 0x1000, 0x17ff, paletteram_xBBBBBGGGGGRRRRR_swap_w, &paletteram },/* palette RAM */
  115.     { 0x1800, 0x1fff, MWA_RAM },                /* Work RAM */
  116.     { 0x2000, 0x27ff, fastlane_vram1_w, &fastlane_videoram1 },
  117.     { 0x2800, 0x2fff, fastlane_vram2_w, &fastlane_videoram2 },
  118.     { 0x3000, 0x3fff, MWA_RAM, &spriteram },    /* Sprite RAM */
  119.     { 0x4000, 0xffff, MWA_ROM },                /* ROM/banked ROM */
  120.     { -1 }    /* end of table */
  121. };
  122.  
  123. /***************************************************************************
  124.  
  125.     Input Ports
  126.  
  127. ***************************************************************************/
  128.  
  129. INPUT_PORTS_START( fastlane )
  130.     PORT_START    /* DSW #1 */
  131.     PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
  132.     PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
  133.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  134.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
  135.     PORT_DIPSETTING(    0x04, DEF_STR( 3C_2C ) )
  136.     PORT_DIPSETTING(    0x01, DEF_STR( 4C_3C ) )
  137.     PORT_DIPSETTING(    0x0f, DEF_STR( 1C_1C ) )
  138.     PORT_DIPSETTING(    0x03, DEF_STR( 3C_4C ) )
  139.     PORT_DIPSETTING(    0x07, DEF_STR( 2C_3C ) )
  140.     PORT_DIPSETTING(    0x0e, DEF_STR( 1C_2C ) )
  141.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_5C ) )
  142.     PORT_DIPSETTING(    0x0d, DEF_STR( 1C_3C ) )
  143.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
  144.     PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
  145.     PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
  146.     PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
  147.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  148.     PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
  149.     PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
  150.     PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
  151.     PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
  152.     PORT_DIPSETTING(    0x40, DEF_STR( 3C_2C ) )
  153.     PORT_DIPSETTING(    0x10, DEF_STR( 4C_3C ) )
  154.     PORT_DIPSETTING(    0xf0, DEF_STR( 1C_1C ) )
  155.     PORT_DIPSETTING(    0x30, DEF_STR( 3C_4C ) )
  156.     PORT_DIPSETTING(    0x70, DEF_STR( 2C_3C ) )
  157.     PORT_DIPSETTING(    0xe0, DEF_STR( 1C_2C ) )
  158.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_5C ) )
  159.     PORT_DIPSETTING(    0xd0, DEF_STR( 1C_3C ) )
  160.     PORT_DIPSETTING(    0xc0, DEF_STR( 1C_4C ) )
  161.     PORT_DIPSETTING(    0xb0, DEF_STR( 1C_5C ) )
  162.     PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
  163.     PORT_DIPSETTING(    0x90, DEF_STR( 1C_7C ) )
  164. //    PORT_DIPSETTING(    0x00, "Invalid" )
  165.  
  166.     PORT_START    /* DSW #2 */
  167.     PORT_DIPNAME( 0x03, 0x02, DEF_STR( Lives ) )
  168.     PORT_DIPSETTING(    0x03, "2" )
  169.     PORT_DIPSETTING(    0x02, "3" )
  170.     PORT_DIPSETTING(    0x01, "4" )
  171.     PORT_DIPSETTING(    0x00, "7" )
  172.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
  173.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  174.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  175.     /* The bonus life affects the starting high score too, 20000 or 30000 */
  176.     PORT_DIPNAME( 0x18, 0x18, DEF_STR( Bonus_Life ) )
  177.     PORT_DIPSETTING(    0x18, "20000 100000" )
  178.     PORT_DIPSETTING(    0x10, "30000 150000" )
  179.     PORT_DIPSETTING(    0x08, "20000" )
  180.     PORT_DIPSETTING(    0x00, "30000" )
  181.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  182.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  183.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  184.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
  185.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  186.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  187.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
  188.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  189.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  190.  
  191.     PORT_START    /* DSW #3 */
  192.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
  193.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  194.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  195.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  196.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  197.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  198.     PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
  199.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  200.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  201.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  202.     PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
  203.  
  204.     PORT_START    /* COINSW */
  205.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  206.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  207.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )    /* service */
  208.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
  209.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START2 )
  210.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
  211.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  212.  
  213.     PORT_START    /* PLAYER 1 INPUTS */
  214.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER1 )
  215.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER1 )
  216.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER1 )
  217.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER1 )
  218.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  219.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  220.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  221.  
  222.     PORT_START    /* PLAYER 2 INPUTS */
  223.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  224.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  225.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  226.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  227.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  228.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  229.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  230.  
  231. INPUT_PORTS_END
  232.  
  233. static struct GfxLayout gfxlayout =
  234. {
  235.     8,8,
  236.     0x80000/32,
  237.     4,
  238.     { 0, 1, 2, 3 },
  239.     { 2*4, 3*4, 0*4, 1*4, 6*4, 7*4, 4*4, 5*4 },
  240.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  241.     32*8
  242. };
  243.  
  244. static struct GfxDecodeInfo gfxdecodeinfo[] =
  245. {
  246.     { REGION_GFX1, 0, &gfxlayout, 0, 64 },
  247.     { -1 } /* end of array */
  248. };
  249.  
  250. /***************************************************************************
  251.  
  252.     Machine Driver
  253.  
  254. ***************************************************************************/
  255.  
  256. static void volume_callback0(int v)
  257. {
  258.     K007232_set_volume(0,0,(v >> 4) * 0x11,0);
  259.     K007232_set_volume(0,1,0,(v & 0x0f) * 0x11);
  260. }
  261.  
  262. static void volume_callback1(int v)
  263. {
  264.     K007232_set_volume(1,0,(v >> 4) * 0x11,0);
  265.     K007232_set_volume(1,1,0,(v & 0x0f) * 0x11);
  266. }
  267.  
  268. static struct K007232_interface k007232_interface =
  269. {
  270.     2,            /* number of chips */
  271.     { REGION_SOUND1, REGION_SOUND2 },    /* memory regions */
  272.     { K007232_VOL(50,MIXER_PAN_CENTER,50,MIXER_PAN_CENTER),
  273.             K007232_VOL(50,MIXER_PAN_LEFT,50,MIXER_PAN_RIGHT) },    /* volume */
  274.     { volume_callback0,  volume_callback1 }    /* external port callback */
  275. };
  276.  
  277. static struct MachineDriver machine_driver_fastlane =
  278. {
  279.     /* basic machine hardware */
  280.     {
  281.         {
  282.             CPU_HD6309,
  283.             3000000,        /* 24MHz/8? */
  284.             fastlane_readmem,fastlane_writemem,0,0,
  285.             fastlane_interrupt,16    /* 1 IRQ + ??? NMI (generated by the 007121) */
  286.         }
  287.     },
  288.     60, DEFAULT_60HZ_VBLANK_DURATION,
  289.     1,
  290.     0,
  291.  
  292.     /* video hardware */
  293.     37*8, 32*8, { 0*8, 35*8-1, 2*8, 30*8-1 },
  294.     gfxdecodeinfo,
  295.     1024, 1024,
  296.     0,
  297.  
  298.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  299.     0,
  300.     fastlane_vh_start,
  301.     0,
  302.     fastlane_vh_screenrefresh,
  303.  
  304.     /* sound hardware */
  305.     0,0,0,0,
  306.     {
  307.         {
  308.             SOUND_K007232,
  309.             &k007232_interface
  310.         }
  311.     }
  312. };
  313.  
  314.  
  315. /***************************************************************************
  316.  
  317.   Game ROMs
  318.  
  319. ***************************************************************************/
  320.  
  321. ROM_START( fastlane )
  322.     ROM_REGION( 0x21000, REGION_CPU1 ) /* code + banked roms */
  323.     ROM_LOAD( "fl_e05.rom", 0x08000, 0x08000, 0xe1004489 )    /* fixed ROM */
  324.     ROM_LOAD( "fl_e04.rom", 0x10000, 0x10000, 0xff4d6029 )    /* banked ROM */
  325.  
  326.     ROM_REGION( 0x80000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  327.     ROM_LOAD( "fl_m02.rom",    0x00000, 0x80000, 0xa126e82d )    /* tiles + sprites */
  328.  
  329.     ROM_REGION( 0x0400, REGION_PROMS )
  330.     ROM_LOAD( "prom1",      0x0000, 0x0100, 0x00000000 )
  331.     ROM_LOAD( "prom2",      0x0100, 0x0100, 0x00000000 )
  332.     ROM_LOAD( "prom3",      0x0200, 0x0100, 0x00000000 )
  333.     ROM_LOAD( "prom4",      0x0300, 0x0100, 0x00000000 )
  334.  
  335.     ROM_REGION( 0x20000, REGION_SOUND1 )    /* 007232 data */
  336.     ROM_LOAD( "fl_m01.rom",    0x00000, 0x20000, 0x85d691ed ) /* chip 1 */
  337.  
  338.     ROM_REGION( 0x80000, REGION_SOUND2 )    /* 007232 data */
  339.     ROM_LOAD( "fl_m03.rom",    0x00000, 0x80000, 0x119e9cbf ) /* chip 2 */
  340. ROM_END
  341.  
  342.  
  343.  
  344. GAMEX( 1987, fastlane, 0, fastlane, fastlane, 0, ROT90, "Konami", "Fast Lane", GAME_NOT_WORKING | GAME_IMPERFECT_COLORS )
  345.